﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kaiser.Modules.Cubic.DomainModel.Advert;
using Kaiser.Modules.Cubic.DomainModel.News;
using Kaiser.Modules.Cubic.Repositories;

namespace Kaiser.Repositories.iBatis.CUBIC
{
    public class AdvertSpaceRepositorie : RepositorieBase<AdvertSpace> ,IAdvertSpaceRepositorie
    {

        public AdvertSpace GetAdvertSpaceByCode(string code)
        {
       
            var result = BatisHepler.ExcuteSelectObj("AdvertSpace.GetByCode", code) as AdvertSpace;

            if (result != null)
            {
                result.AdvertDetail = BatisHepler.ExcuteSelectForList<Advert>("Advert.GetListByCode", result.Id);
            }
            return result;
        }


        public Models.DataGrid<AdvertSpace> Search(Modules.Cubic.ViewModel.AdvertSpaceSearch search, Models.PagingInfo pageinfo)
        {
            var result = new Models.DataGrid<AdvertSpace>();

            int totalCount = 0;

            result.TableResult = BatisHepler.ExcuteSelect("AdvertSpace.Search", search, pageinfo.Size, pageinfo.Index + 1, out totalCount);

            result.total = totalCount;

            return result;
            
        }

        protected override string MapPath
        {
            get { return "SQLMap.CUBIC.config"; }
        }
    }
}
